<?php

include "funct.php";

if (!isset($_POST["name"], $_POST["message"], $_SESSION["user"]))
	iesire();

clean($_POST["name"]);
clean($_POST["message"]);

if (strlen($_POST["name"]) < 2 || strlen($_POST["name"]) > 20)
	msg($lang["name_w"]);
elseif (ok_create($_SESSION["user"]) == 1) { //daca poate crea o camera
	$config = config();
	if (!isset($config))
		$ceas = a_ceas($terminare_b);
	else
		$ceas = a_ceas($config["time_battle1"]);
	mysql_query("insert into " . $db["rooms"] . " set user='" . $_SESSION["user"] . "', name='" . $_POST["name"] . "', message='" . $_POST["message"] . "', end='" . $ceas . "' ");
	$rezultat = mysql_query("select * from " . $db["rooms"] . " where user='" . $_SESSION["user"] . "' and name='" . $_POST["name"] . "' and message='" . $_POST["message"] . "' and end='" . $ceas . "'");
	$rand = mysql_fetch_array($rezultat);
	location("battle&id=" . $rand["id"]);
}
else
	msg($lang["n_create"]);
?>
